#include <jni.h>
#include <string>

extern "C" JNIEXPORT jstring JNICALL
Java_com_example_myapplication_CaculatorActivity_stringFromJNI(
        JNIEnv *env,
        jobject /* this */) {
    std::string hello = "简易计算器";
    return env->NewStringUTF(hello.c_str());
}

extern "C"
JNIEXPORT jfloat JNICALL
Java_com_example_myapplication_CaculatorActivity_operationNumberFromJNI(JNIEnv *env, jobject thiz,
                                                                        jfloat parameter1,
                                                                        jfloat parameter2,
                                                                        jchar type) {
    // TODO: implement operationNumberFromJNI()
    switch (type) {
        case '+':
            return parameter1 + parameter2;
        case '-':
            return parameter1 - parameter2;
        case '*':
            return parameter1 * parameter2;
        case '/':
            return parameter1 / parameter2;
    }
    return parameter1 + parameter2;
}